using System.Collections;
using System.Collections.Generic;
using UI;
using UnityEngine;
using UnityEngine.UI;

public class SlotUI : Singleton<SlotUI>
{
    //UI图片和当前物品信息和是否选中
    public Image itemImage;
    public ItemDetails currentItem;

    public bool isSelect;

    protected override void Awake()
    {
        base.Awake();
        SetEmpty();
        isSelect = false;
    }

    public void SetItem(ItemDetails item)
    {
        currentItem = item;
        this.gameObject.SetActive(true);
        itemImage.sprite = item.itemSprite;
        /*itemImage.SetNativeSize();*/
    }
    public void SetEmpty()
    {
        currentItem = null;
        this.gameObject.SetActive(false);
    }

    public void Select()
    {
        isSelect = !isSelect;
        if (isSelect)
        {
            if (currentItem.itemName == EItemType.魔方)
            {
                UI_LittleGamePanel.StartGame(ELittleGameType.魔方);
                return;
            }
            if (currentItem.itemName == EItemType.带锁日记本)
            {
                UI_LittleGamePanel.StartGame(ELittleGameType.上锁日记);
                return;
            }
            itemImage.color = Color.gray;
            UI_TipPanel.ShowTip($"{currentItem.itemTips}");
        }
            
        else
        {
            itemImage.color = Color.white;
        }
    }


}
